﻿using System;
using System.Collections.Generic;
public class Room
{
    const int AreaNum=40;
    int no;
    string title;
    bool playing;
    UserTable userList = new UserTable();
    Area[] GameBoard = new Area[AreaNum];
    public bool Playing
    {
        set { playing = value; }
        get { return playing; }
    }
    public int No
    {
        set { no = value; }
        get { return no; }
    }
    public string Title
    {
        set { title = value; }
        get { return title; }
    }
    public void Join(User user)
    {
        lock (userList.SyncRoot)
        {
            userList.Add(user);
        }
    }
    public object UserSync
    {
        get
        {
            return userList.SyncRoot;
        }
    }
    public void Init()
    {
        //초기화에 들어간다.
        //0으로 만듬
        foreach (User user in userList)
            user.Money = 250000;
        //나중에 XML로 읽어 구현.
        GameBoard[0] = new EventZone("출발지");

        GameBoard[1] = new Estate("한국","서울",5000);
        GameBoard[2] = new Estate("일본","도코",7000);
        GameBoard[3] = new Estate("중국","북경",4000);
        GameBoard[4] = new Estate("인도", "뉴델리", 2100);
        GameBoard[5] = new Estate("태국", "방콕", 3800);
        GameBoard[6] = new Estate("말레이시아", "콸라룸푸", 3700);
        GameBoard[7] = new Estate("싱가포르", "싱가포르", 5300);
        GameBoard[8] = new Estate("필리핀", "마닐라", 3800);

        GameBoard[9] = new EventZone("무인도");

        GameBoard[10] = new Estate("호주", "시드니", 5000);
        GameBoard[11] = new Estate("칠레", "산티아고", 2700);
        GameBoard[12] = new Estate("아르헨티나", "부에노스아레스", 3000);
        GameBoard[13] = new Estate("브라질","상파울루",3100);
        GameBoard[14] = new EventZone("이벤트카드");
        GameBoard[15] = new Estate("멕시코", "멕시코시티", 3500);
        GameBoard[16] = new Estate("쿠바", "아바나", 1800);
        GameBoard[17] = new Estate("미국", "뉴옥", 7800);
        
        GameBoard[18] = new EventZone("우주정거장");

        GameBoard[19] = new Estate("러시아", "모스크바", 4300);
        GameBoard[20] = new Estate("폴란드","바르샤바",3700);
        GameBoard[21] = new Estate("영국", "런던",5800);
        GameBoard[22] = new Estate("프랑스", "파리", 4500);
        GameBoard[23] = new Estate("스페인","마드리드",4700);
        GameBoard[24] = new Estate("포루투칼","리스본",4300);
        GameBoard[25] = new Estate("독일","베를린",4800);
        GameBoard[26] = new Estate("이탈리아","로마",5000);

        GameBoard[27] = new EventZone("복지기금출금");

        GameBoard[28] = new Estate("튀니지", "튀니스", 2800);
        GameBoard[29] = new Estate("알제리", "알제", 2700);
        GameBoard[30] = new Estate("모르코","카사블랑카",2400);
        GameBoard[31] = new Estate("수단","히트룸",2300);
        GameBoard[32] = new EventZone("복지기금입금");
        GameBoard[33] = new Estate("요르단","암만",3300);
        GameBoard[34] = new Estate("UAE","두바이",5000);
        GameBoard[35] = new Estate("터키","이스탄불",2700);


        //콜백으로 생성되었음을 알린다.
        //
        foreach (User user in userList)
            user.Callback.CallBackMessage("게임이 준비되었습니다.");
    }
    
}

class RoomTable:SynchronizedKeyedCollection<int,Room>
{
    protected override int  GetKeyForItem(Room room)
    {
        return room.No;
    }
}